package time

import (
	"strings"
	"time"
)

var (
	StartTick int64 = time.Now().UnixNano() / 1000000
	TimeStamp int64 = time.Now().UnixNano() / 1000000 / 1000
)

func init() {
	go func() {
		for {
			time.Sleep(time.Millisecond * time.Duration(10))
			TimeStamp = time.Now().UnixNano() / 1000000 / 1000
		}
	}()
}

func Sleep(ms int) {
	time.Sleep(time.Millisecond * time.Duration(ms))
}

func Date() string {
	t := time.Now().Format("2006-01-02 15:04:05")
	s := strings.Split(t, " ")
	if len(s) != 2 {
		return "log date:%v err"
	}

	s[0] = strings.Replace(s[0], "-", "", -1)
	s[1] = strings.Replace(s[1], ":", "", -1)

	return strings.Join(s, "")
}
